package me.baicai.weixin.provider.repository;

import me.baicai.weixin.entity.config.ShopMenu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface ProductRepository  extends JpaRepository<ShopMenu, Long> {


    /**
     *  通过SN码获取一个设备可用的套餐列表 状态为1
     * @param sn
     * @return
     */


    @Query(value = "select s.* from shop_menu s LEFT JOIN device d  on d.shopId = s.shopId where d.sn = ?1 and s.`use` = 1",nativeQuery = true)
    List<ShopMenu> getShopMenyBySN(String sn);

    List<ShopMenu> findAllByShopIdAndIsuse(Integer shopId, int use);
}
